﻿// =================================================================== 
// 项目说明
//====================================================================
// 天网软件股份有限公司
// 文件： SYS_USER.cs
// 项目名称：企业内部管理信息系统


// 创建时间：2013/3/19
// 负责人：
// ===================================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using TWCommonLib.Model;
using TWCommonLib.IDAL;


//注意：该文件自动生成，一般请不要手工修改。




namespace MSSQLDAL
{
    /// <summary>
    /// 数据层实例化接口类 .
    /// </summary>
    public partial class SYS_USERDAL : ISYS_USERDAL
    {
		
		 #region 变量声明（For update 和 Insert 时）
		// 声明静态变量 
		private const string PARA_USER_ID =  "@USER_ID";
		private const string PARA_DEPT_ID =  "@DEPT_ID";
		private const string PARA_IS_MANAGER =  "@IS_MANAGER";
		private const string PARA_USER_NAME =  "@USER_NAME";
		private const string PARA_USER_PASSWORD =  "@USER_PASSWORD";
		private const string PARA_CONTACT_PHONE =  "@CONTACT_PHONE";
		private const string PARA_INNER_PHONE =  "@INNER_PHONE";
		private const string PARA_OFFICE_PHONE =  "@OFFICE_PHONE";
		private const string PARA_HOME_PHONE =  "@HOME_PHONE";
		private const string PARA_E_MAIL =  "@E_MAIL";
		private const string PARA_ADDRESS =  "@ADDRESS";
		private const string PARA_DISPLAY_ORDER =  "@DISPLAY_ORDER";
		private const string PARA_REMARK =  "@REMARK";
		private const string PARA_DERATE_LIMIT =  "@DERATE_LIMIT";
		private const string PARA_USER_TYPE =  "@USER_TYPE";
		private const string PARA_CREATE_OPERATOR_ID =  "@CREATE_OPERATOR_ID";
		private const string PARA_SUB_SYSTEM =  "@SUB_SYSTEM";
		private const string PARA_OTHER_USER1 =  "@OTHER_USER1";
		private const string PARA_OTHER_PWD1 =  "@OTHER_PWD1";
		private const string PARA_OTHER_USER2 =  "@OTHER_USER2";
		private const string PARA_OTHER_PWD2 =  "@OTHER_PWD2";
		private const string PARA_OTHER_USER3 =  "@OTHER_USER3";
		private const string PARA_OTHER_PWD3 =  "@OTHER_PWD3";
		private const string PARA_DEL_FLAG =  "@DEL_FLAG";

		private const string SQL_UPDATE = "UPDATE SYS_USER SET  USER_ID= @USER_ID, DEPT_ID= @DEPT_ID, IS_MANAGER= @IS_MANAGER, USER_NAME= @USER_NAME, USER_PASSWORD= @USER_PASSWORD, CONTACT_PHONE= @CONTACT_PHONE, INNER_PHONE= @INNER_PHONE, OFFICE_PHONE= @OFFICE_PHONE, HOME_PHONE= @HOME_PHONE, E_MAIL= @E_MAIL, ADDRESS= @ADDRESS, DISPLAY_ORDER= @DISPLAY_ORDER, REMARK= @REMARK, DERATE_LIMIT= @DERATE_LIMIT, USER_TYPE= @USER_TYPE, CREATE_OPERATOR_ID= @CREATE_OPERATOR_ID, SUB_SYSTEM= @SUB_SYSTEM, OTHER_USER1= @OTHER_USER1, OTHER_PWD1= @OTHER_PWD1, OTHER_USER2= @OTHER_USER2, OTHER_PWD2= @OTHER_PWD2, OTHER_USER3= @OTHER_USER3, OTHER_PWD3= @OTHER_PWD3, DEL_FLAG= @DEL_FLAG  WHERE USER_ID = @USER_ID ";
		private const string SQL_INSERT = "INSERT INTO SYS_USER(USER_ID, DEPT_ID, IS_MANAGER, USER_NAME, USER_PASSWORD, CONTACT_PHONE, INNER_PHONE, OFFICE_PHONE, HOME_PHONE, E_MAIL, ADDRESS, DISPLAY_ORDER, REMARK, DERATE_LIMIT, USER_TYPE, CREATE_OPERATOR_ID, SUB_SYSTEM, OTHER_USER1, OTHER_PWD1, OTHER_USER2, OTHER_PWD2, OTHER_USER3, OTHER_PWD3, DEL_FLAG ) values ( @USER_ID, @DEPT_ID, @IS_MANAGER, @USER_NAME, @USER_PASSWORD, @CONTACT_PHONE, @INNER_PHONE, @OFFICE_PHONE, @HOME_PHONE, @E_MAIL, @ADDRESS, @DISPLAY_ORDER, @REMARK, @DERATE_LIMIT, @USER_TYPE, @CREATE_OPERATOR_ID, @SUB_SYSTEM, @OTHER_USER1, @OTHER_PWD1, @OTHER_USER2, @OTHER_PWD2, @OTHER_USER3, @OTHER_PWD3, @DEL_FLAG ) ";
		#endregion
		
		// 查询数据的sql串




		private string TableString;
		
		#region 构造函数




		/// <summary>
		/// ??????
		/// </summary>
		public SYS_USERDAL()
		{
			if (QueryDataString == "")
                TableString = "SYS_USER SQL_A";
            else
                TableString = "(" + QueryDataString + ") SQL_A";
		}
		#endregion

        //-----------实例化接口函数-----------
		
		//------------增删改函数------------------- 
		
		#region Add 向数据库中插入一条新记录。




		/// <summary>
		/// 向数据库SYS_USER中插入一条新记录。




		/// </summary>
		/// <param name="_SYS_USERModel">SYS_USER??</param>
		/// <returns>影响的行数</returns>
		public int Add(TWCommonLib.Model.SYS_USER _SYS_USERModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_USER_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_IS_MANAGER, SqlDbType.SmallInt), 
				new SqlParameter(PARA_USER_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_USER_PASSWORD, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTACT_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_INNER_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_OFFICE_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_HOME_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_E_MAIL, SqlDbType.VarChar), 
				new SqlParameter(PARA_ADDRESS, SqlDbType.VarChar), 
				new SqlParameter(PARA_DISPLAY_ORDER, SqlDbType.Int), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_DERATE_LIMIT, SqlDbType.Decimal), 
				new SqlParameter(PARA_USER_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_OPERATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.Int), 
				new SqlParameter(PARA_OTHER_USER1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER3, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD3, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEL_FLAG, SqlDbType.SmallInt)
			};			
			
			 _param[0].Value =  _SYS_USERModel.USER_ID;
			 _param[1].Value =  _SYS_USERModel.DEPT_ID;
			 _param[2].Value =  _SYS_USERModel.IS_MANAGER;
			 _param[3].Value =  _SYS_USERModel.USER_NAME;
			 _param[4].Value =  _SYS_USERModel.USER_PASSWORD;
			 _param[5].Value =  _SYS_USERModel.CONTACT_PHONE;
			 _param[6].Value =  _SYS_USERModel.INNER_PHONE;
			 _param[7].Value =  _SYS_USERModel.OFFICE_PHONE;
			 _param[8].Value =  _SYS_USERModel.HOME_PHONE;
			 _param[9].Value =  _SYS_USERModel.E_MAIL;
			 _param[10].Value =  _SYS_USERModel.ADDRESS;
			 _param[11].Value =  _SYS_USERModel.DISPLAY_ORDER;
			 _param[12].Value =  _SYS_USERModel.REMARK;
			 _param[13].Value =  _SYS_USERModel.DERATE_LIMIT;
			 _param[14].Value =  _SYS_USERModel.USER_TYPE;
			 _param[15].Value =  _SYS_USERModel.CREATE_OPERATOR_ID;
			 _param[16].Value =  _SYS_USERModel.SUB_SYSTEM;
			 _param[17].Value =  _SYS_USERModel.OTHER_USER1;
			 _param[18].Value =  _SYS_USERModel.OTHER_PWD1;
			 _param[19].Value =  _SYS_USERModel.OTHER_USER2;
			 _param[20].Value =  _SYS_USERModel.OTHER_PWD2;
			 _param[21].Value =  _SYS_USERModel.OTHER_USER3;
			 _param[22].Value =  _SYS_USERModel.OTHER_PWD3;
			 _param[23].Value =  _SYS_USERModel.DEL_FLAG;

			
			//  返回
			return (int)SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, SQL_INSERT, _param);


		}
		#endregion
		
		#region Add 向数据库中插入一条新记录。带事务
		/// <summary>
		/// 向数据库SYS_USER中插入一条新记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="_SYS_USERModel">SYS_USER实体</param>
		/// <returns>影响的行数</returns>
		public int Add(DBTransaction dbTrans,TWCommonLib.Model.SYS_USER _SYS_USERModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_USER_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_IS_MANAGER, SqlDbType.SmallInt), 
				new SqlParameter(PARA_USER_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_USER_PASSWORD, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTACT_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_INNER_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_OFFICE_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_HOME_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_E_MAIL, SqlDbType.VarChar), 
				new SqlParameter(PARA_ADDRESS, SqlDbType.VarChar), 
				new SqlParameter(PARA_DISPLAY_ORDER, SqlDbType.Int), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_DERATE_LIMIT, SqlDbType.Decimal), 
				new SqlParameter(PARA_USER_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_OPERATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.Int), 
				new SqlParameter(PARA_OTHER_USER1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER3, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD3, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEL_FLAG, SqlDbType.SmallInt)
			};	
			
			 _param[0].Value =  _SYS_USERModel.USER_ID;
			 _param[1].Value =  _SYS_USERModel.DEPT_ID;
			 _param[2].Value =  _SYS_USERModel.IS_MANAGER;
			 _param[3].Value =  _SYS_USERModel.USER_NAME;
			 _param[4].Value =  _SYS_USERModel.USER_PASSWORD;
			 _param[5].Value =  _SYS_USERModel.CONTACT_PHONE;
			 _param[6].Value =  _SYS_USERModel.INNER_PHONE;
			 _param[7].Value =  _SYS_USERModel.OFFICE_PHONE;
			 _param[8].Value =  _SYS_USERModel.HOME_PHONE;
			 _param[9].Value =  _SYS_USERModel.E_MAIL;
			 _param[10].Value =  _SYS_USERModel.ADDRESS;
			 _param[11].Value =  _SYS_USERModel.DISPLAY_ORDER;
			 _param[12].Value =  _SYS_USERModel.REMARK;
			 _param[13].Value =  _SYS_USERModel.DERATE_LIMIT;
			 _param[14].Value =  _SYS_USERModel.USER_TYPE;
			 _param[15].Value =  _SYS_USERModel.CREATE_OPERATOR_ID;
			 _param[16].Value =  _SYS_USERModel.SUB_SYSTEM;
			 _param[17].Value =  _SYS_USERModel.OTHER_USER1;
			 _param[18].Value =  _SYS_USERModel.OTHER_PWD1;
			 _param[19].Value =  _SYS_USERModel.OTHER_USER2;
			 _param[20].Value =  _SYS_USERModel.OTHER_PWD2;
			 _param[21].Value =  _SYS_USERModel.OTHER_USER3;
			 _param[22].Value =  _SYS_USERModel.OTHER_PWD3;
			 _param[23].Value =  _SYS_USERModel.DEL_FLAG;

			
			//  返回
			return (int)SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, SQL_INSERT, _param);
		}
		#endregion
		
		#region	Update 向数据表更新一条记录。	
		/// <summary>
		/// 向数据表SYS_USER更新一条记录。




		/// </summary>
		/// <param name="_SYS_USERModel">_SYS_USERModel</param>
		/// <returns>影响的行数</returns>
		public int Update(TWCommonLib.Model.SYS_USER _SYS_USERModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_USER_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_IS_MANAGER, SqlDbType.SmallInt), 
				new SqlParameter(PARA_USER_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_USER_PASSWORD, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTACT_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_INNER_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_OFFICE_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_HOME_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_E_MAIL, SqlDbType.VarChar), 
				new SqlParameter(PARA_ADDRESS, SqlDbType.VarChar), 
				new SqlParameter(PARA_DISPLAY_ORDER, SqlDbType.Int), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_DERATE_LIMIT, SqlDbType.Decimal), 
				new SqlParameter(PARA_USER_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_OPERATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.Int), 
				new SqlParameter(PARA_OTHER_USER1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER3, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD3, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEL_FLAG, SqlDbType.SmallInt)
			};	
			
			 _param[0].Value =  _SYS_USERModel.USER_ID;
			 _param[1].Value =  _SYS_USERModel.DEPT_ID;
			 _param[2].Value =  _SYS_USERModel.IS_MANAGER;
			 _param[3].Value =  _SYS_USERModel.USER_NAME;
			 _param[4].Value =  _SYS_USERModel.USER_PASSWORD;
			 _param[5].Value =  _SYS_USERModel.CONTACT_PHONE;
			 _param[6].Value =  _SYS_USERModel.INNER_PHONE;
			 _param[7].Value =  _SYS_USERModel.OFFICE_PHONE;
			 _param[8].Value =  _SYS_USERModel.HOME_PHONE;
			 _param[9].Value =  _SYS_USERModel.E_MAIL;
			 _param[10].Value =  _SYS_USERModel.ADDRESS;
			 _param[11].Value =  _SYS_USERModel.DISPLAY_ORDER;
			 _param[12].Value =  _SYS_USERModel.REMARK;
			 _param[13].Value =  _SYS_USERModel.DERATE_LIMIT;
			 _param[14].Value =  _SYS_USERModel.USER_TYPE;
			 _param[15].Value =  _SYS_USERModel.CREATE_OPERATOR_ID;
			 _param[16].Value =  _SYS_USERModel.SUB_SYSTEM;
			 _param[17].Value =  _SYS_USERModel.OTHER_USER1;
			 _param[18].Value =  _SYS_USERModel.OTHER_PWD1;
			 _param[19].Value =  _SYS_USERModel.OTHER_USER2;
			 _param[20].Value =  _SYS_USERModel.OTHER_PWD2;
			 _param[21].Value =  _SYS_USERModel.OTHER_USER3;
			 _param[22].Value =  _SYS_USERModel.OTHER_PWD3;
			 _param[23].Value =  _SYS_USERModel.DEL_FLAG;
			
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, SQL_UPDATE, _param);
		}
		#endregion
		
		#region	Update 向数据表更新一条记录。带事务	
		/// <summary>
		/// 向数据表SYS_USER更新一条记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="_SYS_USERModel">_SYS_USERModel</param>
		/// <returns>影响的行数</returns>
		public int Update(DBTransaction dbTrans,TWCommonLib.Model.SYS_USER _SYS_USERModel)
		{
           // 声明参数数组并赋值




		    SqlParameter[] _param=
			{
				new SqlParameter(PARA_USER_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_IS_MANAGER, SqlDbType.SmallInt), 
				new SqlParameter(PARA_USER_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_USER_PASSWORD, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTACT_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_INNER_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_OFFICE_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_HOME_PHONE, SqlDbType.VarChar), 
				new SqlParameter(PARA_E_MAIL, SqlDbType.VarChar), 
				new SqlParameter(PARA_ADDRESS, SqlDbType.VarChar), 
				new SqlParameter(PARA_DISPLAY_ORDER, SqlDbType.Int), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_DERATE_LIMIT, SqlDbType.Decimal), 
				new SqlParameter(PARA_USER_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_OPERATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.Int), 
				new SqlParameter(PARA_OTHER_USER1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD1, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD2, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_USER3, SqlDbType.VarChar), 
				new SqlParameter(PARA_OTHER_PWD3, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEL_FLAG, SqlDbType.SmallInt)
			};		
			
			 _param[0].Value =  _SYS_USERModel.USER_ID;
			 _param[1].Value =  _SYS_USERModel.DEPT_ID;
			 _param[2].Value =  _SYS_USERModel.IS_MANAGER;
			 _param[3].Value =  _SYS_USERModel.USER_NAME;
			 _param[4].Value =  _SYS_USERModel.USER_PASSWORD;
			 _param[5].Value =  _SYS_USERModel.CONTACT_PHONE;
			 _param[6].Value =  _SYS_USERModel.INNER_PHONE;
			 _param[7].Value =  _SYS_USERModel.OFFICE_PHONE;
			 _param[8].Value =  _SYS_USERModel.HOME_PHONE;
			 _param[9].Value =  _SYS_USERModel.E_MAIL;
			 _param[10].Value =  _SYS_USERModel.ADDRESS;
			 _param[11].Value =  _SYS_USERModel.DISPLAY_ORDER;
			 _param[12].Value =  _SYS_USERModel.REMARK;
			 _param[13].Value =  _SYS_USERModel.DERATE_LIMIT;
			 _param[14].Value =  _SYS_USERModel.USER_TYPE;
			 _param[15].Value =  _SYS_USERModel.CREATE_OPERATOR_ID;
			 _param[16].Value =  _SYS_USERModel.SUB_SYSTEM;
			 _param[17].Value =  _SYS_USERModel.OTHER_USER1;
			 _param[18].Value =  _SYS_USERModel.OTHER_PWD1;
			 _param[19].Value =  _SYS_USERModel.OTHER_USER2;
			 _param[20].Value =  _SYS_USERModel.OTHER_PWD2;
			 _param[21].Value =  _SYS_USERModel.OTHER_USER3;
			 _param[22].Value =  _SYS_USERModel.OTHER_PWD3;
			 _param[23].Value =  _SYS_USERModel.DEL_FLAG;
			

			
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, SQL_UPDATE, _param);
		}
		#endregion
		
		#region	Delete 根据主键，删除数据表中的一条记录	
		/// <summary>
		/// 根据主键，删除数据表SYS_USER中的一条记录




		/// </summary>
	    /// <param name="uSER_ID">uSER_ID</param>
		/// <returns>影响的行数</returns>
		public int Delete(string uSER_ID)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@uSER_ID", SqlDbType.VarChar)
			};				
			_param[0].Value = uSER_ID;
			
			string sqlStr="delete from SYS_USER where  USER_ID=@uSER_ID";
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, sqlStr, _param);;
		}
		#endregion
		
		#region	Delete 根据主键，删除数据表中的一条记录 带事务




		/// <summary>
		/// 根据主键，删除数据表SYS_USER中的一条记录 带事务




		/// <param name="sp">事务对象</param>
	    /// <param name="USER_ID">uSER_ID</param>
		/// <returns>影响的行数</returns>
		public int Delete(DBTransaction dbTrans,string uSER_ID)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@uSER_ID", SqlDbType.VarChar)
			};				
			_param[0].Value = uSER_ID;

			string sqlStr="delete from SYS_USER where  USER_ID=@uSER_ID";
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, sqlStr,_param);;

		}
		#endregion
		
		#region	DeleteFK 根据条件串，删除数据表中的N条记录	
		/// <summary>
		/// 根据条件串，删除数据表SYS_USER中的N条记录




		/// </summary>
	    /// <param name="sWhere">条件串</param>
		/// <returns>影响的行数</returns>
		public int DeleteFK(string sWhere)
		{
			string  sqlStr="delete from SYS_USER";
			if (sWhere.Length>0)
				sqlStr += " where "+sWhere;
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, sqlStr);
		}
		#endregion
		
		#region	DeleteFK 删除数据表中的一条记录,带事务	
		/// <summary>
		/// 删除数据表SYS_USER中的一条记录,带事务




		/// </summary>
		/// <param name="sp">事务对象</param>
	    /// <param name="sWhere">条件串</param>
		/// <returns>影响的行数</returns>
		public int DeleteFK(DBTransaction dbTrans,string sWhere)
		{
			string  sqlStr="delete from SYS_USER";
			if (sWhere.Length>0)
				sqlStr += " where "+sWhere;
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, sqlStr);
		}
		
		#endregion
		
		
		//------------获取数据及模型函数




		
		#region Exists 检测是否存在该主键
		/// <summary>
        /// 检测是否存在该主键
        /// </summary>
        /// <param name="string uSER_ID" 主键列表</param>
        /// <returns>是/否</returns>
		public bool Exists(string uSER_ID)
		{
			
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@uSER_ID", SqlDbType.VarChar)
			};				
			_param[0].Value = uSER_ID;
			
            string sqlStr="select Count(*) from SYS_USER where  USER_ID=@uSER_ID and USER_ID=@uSER_ID";
						
            int a=Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr,_param));
            if(a>0)
            {
                return true;
            }
            else
            {
                return false;
            }
		}

		#endregion

		#region GetModel 根据主键ID,得到数据实体
        /// <summary>
		/// 根据主键ID,得到 sys_user 数据实体
		/// </summary>
		/// <param name="string uSER_ID" 主键列表</param>
		/// <returns>sys_user 数据实体</returns>
		public TWCommonLib.Model.SYS_USER GetModel(string uSER_ID )
		{
			TWCommonLib.Model.SYS_USER _obj=null;
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@uSER_ID", SqlDbType.VarChar)
			};				
			_param[0].Value = uSER_ID;
			
			string sqlStr="select * from SYS_USER where  USER_ID=@uSER_ID";
			using(SqlDataReader dr=SqlHelper.ExecuteReader(Conn.SqlConnStr,CommandType.Text,sqlStr,_param))
			{
				while(dr.Read())
				{
            		_obj=PopulateSYS_USERModelFromDr(dr);
				}
			}
			return _obj;
		}
		#endregion
		
		#region ----根据DataRow,得到 数据实体
		/// <summary>
		/// 得到  sys_user 数据实体
		/// </summary>
		/// <param name="row">row</param>
		/// <returns>sys_user 数据实体</returns>
		public TWCommonLib.Model.SYS_USER PopulateSYS_USERModelFromDr(DataRow row)
		{
			TWCommonLib.Model.SYS_USER Obj = new TWCommonLib.Model.SYS_USER();
			if(row!=null)
			{
				Obj.USER_ID =  row["USER_ID"].ToString();
				Obj.DEPT_ID =  row["DEPT_ID"].ToString();
				Obj.IS_MANAGER = (short) row["IS_MANAGER"];
				Obj.USER_NAME =  row["USER_NAME"].ToString();
				Obj.USER_PASSWORD =  row["USER_PASSWORD"].ToString();
				Obj.CONTACT_PHONE =  row["CONTACT_PHONE"].ToString();
				Obj.INNER_PHONE =  row["INNER_PHONE"].ToString();
				Obj.OFFICE_PHONE =  row["OFFICE_PHONE"].ToString();
				Obj.HOME_PHONE =  row["HOME_PHONE"].ToString();
				Obj.E_MAIL =  row["E_MAIL"].ToString();
				Obj.ADDRESS =  row["ADDRESS"].ToString();
				Obj.DISPLAY_ORDER = (( row["DISPLAY_ORDER"])==DBNull.Value)?0:Convert.ToInt32( row["DISPLAY_ORDER"]);
				Obj.REMARK =  row["REMARK"].ToString();
				Obj.DERATE_LIMIT = (( row["DERATE_LIMIT"])==DBNull.Value)?0:Convert.ToDecimal( row["DERATE_LIMIT"]);
				Obj.USER_TYPE = (( row["USER_TYPE"])==DBNull.Value)?0:Convert.ToInt32( row["USER_TYPE"]);
				Obj.CREATE_OPERATOR_ID =  row["CREATE_OPERATOR_ID"].ToString();
				Obj.SUB_SYSTEM = (( row["SUB_SYSTEM"])==DBNull.Value)?0:Convert.ToInt32( row["SUB_SYSTEM"]);
				Obj.OTHER_USER1 =  row["OTHER_USER1"].ToString();
				Obj.OTHER_PWD1 =  row["OTHER_PWD1"].ToString();
				Obj.OTHER_USER2 =  row["OTHER_USER2"].ToString();
				Obj.OTHER_PWD2 =  row["OTHER_PWD2"].ToString();
				Obj.OTHER_USER3 =  row["OTHER_USER3"].ToString();
				Obj.OTHER_PWD3 =  row["OTHER_PWD3"].ToString();
				Obj.DEL_FLAG = (short) row["DEL_FLAG"];
			}
			else
			{
				return null;
			}
			return Obj;
		}
		#endregion
		
		#region ----根据IDataReader,得到 数据实体
        /// <summary>
		/// 得到  sys_user 数据实体
		/// </summary>
		/// <param name="dr">dr</param>
		/// <returns>sys_user 数据实体</returns>
		public TWCommonLib.Model.SYS_USER PopulateSYS_USERModelFromDr(IDataReader dr)
		{
			TWCommonLib.Model.SYS_USER Obj = new TWCommonLib.Model.SYS_USER();
			
				Obj.USER_ID =  dr["USER_ID"].ToString();
				Obj.DEPT_ID =  dr["DEPT_ID"].ToString();
				Obj.IS_MANAGER = (short) dr["IS_MANAGER"];
				Obj.USER_NAME =  dr["USER_NAME"].ToString();
				Obj.USER_PASSWORD =  dr["USER_PASSWORD"].ToString();
				Obj.CONTACT_PHONE =  dr["CONTACT_PHONE"].ToString();
				Obj.INNER_PHONE =  dr["INNER_PHONE"].ToString();
				Obj.OFFICE_PHONE =  dr["OFFICE_PHONE"].ToString();
				Obj.HOME_PHONE =  dr["HOME_PHONE"].ToString();
				Obj.E_MAIL =  dr["E_MAIL"].ToString();
				Obj.ADDRESS =  dr["ADDRESS"].ToString();
				Obj.DISPLAY_ORDER = (( dr["DISPLAY_ORDER"])==DBNull.Value)?0:Convert.ToInt32( dr["DISPLAY_ORDER"]);
				Obj.REMARK =  dr["REMARK"].ToString();
				Obj.DERATE_LIMIT = (( dr["DERATE_LIMIT"])==DBNull.Value)?0:Convert.ToDecimal( dr["DERATE_LIMIT"]);
				Obj.USER_TYPE = (( dr["USER_TYPE"])==DBNull.Value)?0:Convert.ToInt32( dr["USER_TYPE"]);
				Obj.CREATE_OPERATOR_ID =  dr["CREATE_OPERATOR_ID"].ToString();
				Obj.SUB_SYSTEM = (( dr["SUB_SYSTEM"])==DBNull.Value)?0:Convert.ToInt32( dr["SUB_SYSTEM"]);
				Obj.OTHER_USER1 =  dr["OTHER_USER1"].ToString();
				Obj.OTHER_PWD1 =  dr["OTHER_PWD1"].ToString();
				Obj.OTHER_USER2 =  dr["OTHER_USER2"].ToString();
				Obj.OTHER_PWD2 =  dr["OTHER_PWD2"].ToString();
				Obj.OTHER_USER3 =  dr["OTHER_USER3"].ToString();
				Obj.OTHER_PWD3 =  dr["OTHER_PWD3"].ToString();
				Obj.DEL_FLAG = (short) dr["DEL_FLAG"];
			
			return Obj;
		}
		#endregion
///
		#region GetNewID 通过种子得到唯一ID,对单主键有效单，如果该表为多主键，则返回第一主键
		/// <summary>
        ///  通过种子得到唯一ID,对单主键有效单，如果该表为多主键，则返回第一主键
        /// </summary>
        /// <param name="uSER_ID">uSER_ID</param>
        /// <returns>string</returns>
		public int GetNewID()
		{
			return  DBCommon.GetNewIDForTable("SYS_USER","SYS_USER","");
		}
		#endregion
///
		#region	GetMaxID 得到最大ID	
		/// <summary>
		/// 得到最大ID
		/// </summary>
        /// <param name="uSER_ID">uSER_ID</param>
        /// <returns>string</returns>
		public int GetMaxID()
		{
			return  0;
		}
		#endregion
		
		#region	GetList 得到数据表指定字段列表的所有记录，可排序，
		/// <summary>
		/// 得到数据表SYS_USER所有记录，可排序




		/// </summary>
        /// <param name="sWhere">条件字符串</param>
        /// <param name="sOder">排序字段</param>
		/// <returns>DataSet</returns>
		public DataSet GetList(string sWhere, string sOder)
		{
			string	sqlStr="select * from "+TableString;
				
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			if (sOder.Length > 0)
				sqlStr += " order by " + sOder;
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion

		#region	GetListFS 得到数据表指定字段列表的所有记录，可排序，加工作流状态字段




		/// <summary>
		/// 得到数据表SYS_USER所有记录，可排序，加工作流状态字段




		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
        /// <param name="sWhere">条件字符串</param>
        /// <param name="sOder">排序字段</param>
		/// <returns>DataSet</returns>
		public DataSet GetListFS(string FlowProcessId, string sWhere, string sOder)
		{
			string	sqlStr="select SQL_A.*, isnull(SQL_B.work_state,'未发送') work_state from "+TableString+" left join view_wfInstance_state SQL_B on SQL_a.work_id=SQL_b.work_id";
				
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			if (sOder.Length > 0)
				sqlStr += " order by " + sOder;
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion


		#region GetPageList 根据条件和页号得到某页的记录集,+排序
		/// <summary>
		/// 根据条件和页号得到某页的记录集,+排序
		/// </summary>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="iPageIndex">页号</param>
		/// <param name="sWhere">条件字符串</param>
		/// <param name="sOder">排序字段</param>
        /// <returns>DataSet</returns>
		public DataSet GetPageList(int iPageSize,int iPageIndex, string sWhere, string sOder)
		{
			if (sOder.Length <=0)
				sOder = "USER_ID";
				
			string	sqlStr="select * from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, * from "+TableString;
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			sqlStr += ") SQL1 where row between "+ Convert.ToString(iPageSize*(iPageIndex-1)+1) +" and "+Convert.ToString(iPageSize*iPageIndex);
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion		

		#region GetPageListFS 根据条件和页号得到某页的记录集,+排序，加工作流状态字段




		/// <summary>
		/// 根据条件和页号得到某页的记录集,+排序，加工作流状态字段




		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="iPageIndex">页号</param>
		/// <param name="sWhere">条件字符串</param>
		/// <param name="sOder">排序字段</param>
        /// <returns>DataSet</returns>
		public DataSet GetPageListFS(string FlowProcessId, int iPageSize,int iPageIndex, string sWhere, string sOder)
		{
			if (sOder.Length <=0)
				sOder = "USER_ID";
				
			string	sqlStr="select * from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, SQL_A.*,isnull(SQL_B.work_state,'未发送') work_state from "+TableString+" left join view_wfInstance_state SQL_B on sql_a.work_id=sql_b.work_id";
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			sqlStr += ") SQL1 where row between "+ Convert.ToString(iPageSize*(iPageIndex-1)+1) +" and "+Convert.ToString(iPageSize*iPageIndex);
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion		
		
		
		#region GetRecorderRowNum 判断某条记录所在的行号
		/// <summary>
		/// 判断某条记录所在的行号，调用者自己计算页号和行号
		/// </summary>
        /// <param name="sWhere">记录显示的条件</param>
        /// <param name="sOder">排序条件</param>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="主键列表">主键列表，需定位记录的键值</param>
        /// <returns>int 页码</returns>
		public int GetRecorderRowNum(string sWhere, string sOder, int iPageSize, string uSER_ID)
		{
			if (sOder.Length <=0)
				sOder = "USER_ID";
				
			// 声明参数数组并赋值



			SqlParameter[] _param=
			{
				new SqlParameter("@uSER_ID", SqlDbType.VarChar)
			};				
			_param[0].Value = uSER_ID;
			
			string	sqlStr="select row from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, uSER_ID from "+TableString;
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
				
			sqlStr = sqlStr + ") SQL1 where  USER_ID=@uSER_ID";
			return Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr,_param));
		}
		#endregion
		
						
		#region GetRecorderCount 得到符合条件记录集的记录条数
		/// <summary>
		/// 得到符合条件记录集的记录条数
		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
		/// <param name="sWhere">条件字符串</param>
        /// <returns>int 记录数</returns>
		public int GetRecorderCount(string FlowProcessId, string sWhere)
		{
			string sqlStr ="";
			
			if (FlowProcessId.Length > 0)
            	sqlStr="select Count(*) from "+TableString+" left join view_wfInstance_state SQL_B on SQL_a.work_id=SQL_b.work_id";
			else
				sqlStr="select Count(*) from "+TableString;
				
			if (sWhere.Length>0)
				sqlStr += " where " + sWhere;
						
            return Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr));
		}
		#endregion				
		
		#region----------自定义实例化接口函数----------
		#endregion
    }
}
